TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1import { withUser, parseBody, json } from "@/lib/api";2import { getPrompt, updatePrompt, deletePrompt, toPublicPrompt } from "@/lib/prompts/service";3import { promptBodySchema } from "@/lib/prompts/schemas";45export const dynamic = "force-dynamic";67type P = { id: string };89/** GET /api/prompts/:id → { prompt } */10export const GET = withUser<P>(async ({ user }, { id }) => json({ prompt: toPublicPrompt(await getPrompt(user.id, id)) }));1112/** PATCH /api/prompts/:id (any subset of the create body) → { prompt } */13export const PATCH = withUser<P>(async ({ req, user }, { id }) => {14 const body = await parseBody(req, promptBodySchema.partial());15 return json({ prompt: await updatePrompt(user.id, id, body) });16});1718export const DELETE = withUser<P>(async ({ user }, { id }) => {19 await deletePrompt(user.id, id);20 return json({ ok: true });21});22